<!DOCTYPE html>
<html lang="en">
<script src="jquery.min.js"></script>

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="css/message.css">
</head>
<style>
    li>button {
        float: right;
    }
</style>

<body>
    <div>
        <h1>留言板</h1>
        <ul></ul>
        <textarea placeholder="请编辑您的留言"></textarea>
        <button class="sub">发布</button>
    </div>
    <script>
        $(".sub").click(function() {
            var con = $("textarea").val();
            if (con != null) {
                $("ul").prepend($("<li>" + con + "<button class='de'>删除</button>" + "</li>"))
                $("textarea").val("");
            };

        });

        $("ul").on("click", ".de", function() {
            $(this).parent("li").remove();
        });
    </script>
</body>


</html>